<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="<%=basePath %>/resource/js/common-css-js.js"></script>
<title>采购计划-采购</title>
<style type="text/css">
	 .radio-vertical-center {
		margin-top:-2px !important;
		vertical-align:middle;
	}
	
	label:hover {
		cursor: pointer;
	}
	
	.radio-box {
	    position: relative;
	    left: 50%;
	    transform: translateX(-50%);
	}
	
	body {
		margin-top: 7%;
	}
	
	.bottom-center {
	    position: absolute;
	    bottom: 3%;
	    left: 50%;
	    transform: translateX(-50%);
	}
	
</style>
</head>
<body>
	<div class="layui-row">
		<form id="buyer-form">
			<div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
				<div class="radio-box layui-badge layui-bg-green">
					<input id="buyer_ok" type="radio" class="radio-vertical-center" name="buyer" value="3" title="采购完成">
					<label for="buyer_ok">采购完成</label>
				</div>
			</div>
	    	<div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
	    		<div class="radio-box layui-badge">
		    		<input id="buyer_error" type="radio" class="radio-vertical-center" name="buyer" value="4" title="采购出错">
					<label for="buyer_error">采购出错</label>
	    		</div>
			</div>
			<div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
				<div class="radio-box layui-badge layui-bg-orange">
					<input id="buyer_again" type="radio" class="radio-vertical-center" name="buyer" value="5" title="重新采购">
					<label for="buyer_again">重新采购</label>
				</div>
			</div>
			<input onclick="submitForm()" class="bottom-center layui-btn layui-btn-sm layui-btn-primary" value="更新采购状态" type="button"/>
		</form>
	</div>
	<script>
	   function submitForm(){
		   var formKVArray = $("#buyer-form").serializeArray();
		   if(formKVArray.length>0){
			   var selectedObj = parent.cTable.bootstrapTable('getSelections');
			   
			   selectedObj[0].procurePlanBuyerStatus = formKVArray[0].value;
			   
			   if(formKVArray[0].value=="5"){
				   selectedObj[0].procurePlanCheckStatus = "5";
			   }
			   
			   $.ajax({
				   type: 'PUT',
				   url: path+"/procurement/procurement-plan?method=put",
				   data: JSON.stringify(selectedObj[0]),
				   contentType: "application/json;charset='UTF-8'",
				   async: false,
				   statusCode: {
					   200: function(){
						   fixedAlert("更新采购状态成功!",1,true,true);
					   },
					   400: function() {
						   fixedAlert("更新采购状态失败!",0,false);
					   },
					   500: function(){
						   fixedAlert("服务器繁忙,请联系管理员!",2,false);
					   }
				   }
				});
		   }else{
			   fixedAlert("请选择要更新的状态!",0);
		   }
	   }
	</script>
</body>
</html>